package cn.framelife.rainbow.db;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import cn.framelife.rainbow.db.entity.Type;

/**
 * sql类型转换为Java类型
 *
 * @ClassName: TypeCoversion 
 * @author 潘广伟  p_3er@qq.com 
 * @date 2013年11月22日 下午2:36:14 
 *
 */
public class TypeCoversion {
	private Properties types;
	public TypeCoversion(String configFile) throws IOException{
		types = new Properties();
		InputStream driverNamesIn = getClass().getResourceAsStream(configFile);
		types.load(driverNamesIn);
	}

	public Type converJavaType(String sqlType) {
		String[] value = types.getProperty(sqlType).split(";");
		Type type = new Type();
		type.setSqlType(sqlType);
		
		type.setJavaType(value[0]);
		type.setJavaTypePackage(value[1]);
		
		return type;
	}
}
